<div [formGroup]="form" class="age-input">
  <mat-form-field>
    <input matInput formControlName="birthday" [matDatepicker]="picker" placeholder="出生日期">
    <mat-error>日期不正确</mat-error>
    <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
    <mat-datepicker #picker></mat-datepicker>
  </mat-form-field>
  <ng-container formGroupName="age">
    <div class="age-num">
      <mat-form-field>
        <input matInput type="number" formControlName="ageNum" placeholder="年龄">
      </mat-form-field>
    </div>
    <div>
      <mat-button-toggle-group formControlName="ageUnit" [(ngModel)]="selectedUnit">
        <mat-button-toggle *ngFor="let unit of ageUnits" [value]="unit.value">
          {{unit.label}}
        </mat-button-toggle>
      </mat-button-toggle-group>
    </div>
    <mat-error *ngIf="form.get('age').hasError('ageInvaild')">年龄或单位不正确</mat-error>
  </ng-container>
</div>
